package com.leyou.sms.config;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 虎哥
 */
@EnableConfigurationProperties(SmsProperties.class)
@Configuration
public class SmsConfig {

    @Bean
    public IAcsClient acsClient(SmsProperties prop){
        DefaultProfile profile = DefaultProfile.getProfile(
                prop.getRegionID(), prop.getAccessKeyID(), prop.getAccessKeySecret());
        return new DefaultAcsClient(profile);
    }

    @Bean
    public Queue deadQueue(){
        return QueueBuilder.durable("xx")
                .withArgument("x-message-ttl", 2000)
                .withArgument("x-dead-letter-exchange", "amq.topic")
                .withArgument("x-dead-letter-routing-key", "overdue.order")
                .build();
    }
}
